<?php

    Class Session
    {
        static function getUser()
        {
            if (isset($_SESSION["idUsuario"]) )
            {
                return UsuariosDAO::getById($_SESSION["idUsuario"]);
            }
            else
                return null;
        }

        static function onlyUsers()
        {
            if ( Session::getUser() == null )
            {
                header( 'Location: ?action=login' ) ;
            }
        }

        static function onlyAdmins()
        {
            self::onlyUsers();

            if (Session::getUser() != null && Session::getUser()->tipoUsuario != 1)
            {
                header( 'Location: ?action=login' ) ;
            }
        }

    }

?>
